#include <iostream>
#include <vector>

int main() {
    // 预计算1到100的五次方
    std::vector<long long> pow5(101);
    for (int i = 1; i <= 100; ++i) {
        pow5[i] = (long long)i * i * i * i * i;
    }

    // 遍历F从1到100
    for (int F = 1; F <= 100; ++F) {
        const long long target = pow5[F];

        // 剪枝1：如果5*1^5 > F^5，说明至少需要有一个数大于1，但此时无法满足A<=B<=C<=D<=E<=F
        if (5 * pow5[1] > target) continue;

        // 遍历E从可能的最小值到F
        for (int E = 1; E <= F; ++E) {
            const long long sumE = pow5[E];

            // 剪枝2：如果E^5超过目标，后续更大E也会超，直接跳出
            if (sumE > target) break;

            // 剪枝3：如果剩余4个数的最大可能和（4*E^5）加上当前E^5仍不足目标
            if (sumE + 4 * pow5[E] < target) continue;

            // 遍历D从1到E
            for (int D = 1; D <= E; ++D) {
                const long long sumED = sumE + pow5[D];

                // 剪枝4：前两数之和超过目标
                if (sumED > target) break;

                // 剪枝5：剩余3个数的最大可能和（3*D^5）加上当前和仍不足
                if (sumED + 3 * pow5[D] < target) continue;

                // 遍历C从1到D
                for (int C = 1; C <= D; ++C) {
                    const long long sumEDC = sumED + pow5[C];

                    if (sumEDC > target) break;
                    if (sumEDC + 2 * pow5[C] < target) continue;

                    // 遍历B从1到C
                    for (int B = 1; B <= C; ++B) {
                        const long long sumEDCB = sumEDC + pow5[B];

                        if (sumEDCB > target) break;
                        if (sumEDCB + pow5[B] < target) continue;

                        // 遍历A从1到B
                        for (int A = 1; A <= B; ++A) {
                            const long long total = sumEDCB + pow5[A];
                            if (total == target) {
                                std::cout << A << " " << B << " " << C << " " << D << " " << E << " " << F << std::endl;
                            }
                        }
                    }
                }
            }
        }
    }
    return 0;
}